import Instance from "@/api/Utils/request.js";
import path from "./path";

const api = {

    //#region 关于jwt
    //解析jwt令牌
    ParseJwt(jwt){
        return Instance.get(path.baseUrl + `/common/ParseJwt/${jwt}`)
    },

    //#endregion


    //#region 关于新闻里面的文件
    // 删除新闻里面的文件（存在了云存储上，无用的文件会占用空间）
    deleteObject(fullPathList){
        return Instance.post(path.baseUrl + "/common/deleteObject",fullPathList)
    },
    // 将文件路径存入后端的临时文件表里
    addTempFile(fp){
        return Instance.post(path.baseUrl + "/common/addTempFile",null,{
            params: {
                fullPath: fp
            }
        })
    },
    // 删除临时文件标记表的信息
    deleteTempFile(fullPathList){
        return Instance.post(path.baseUrl + "/common/deleteTempFile",fullPathList)
    },

    //#endregion


    //#region 关于新闻
    //发布新闻
    addNews(newsAddDTO){
        return Instance.post(path.baseUrl + '/news/add', newsAddDTO);
    },
    //删除新闻（单删）
    deleteOneNews(id){
        return Instance.delete(path.baseUrl + `/news/delete/${id}`)
    },
    //删除浏览记录
    deleteHistory(InputNewsIdList, InputUserId){
        return Instance.delete(path.baseUrl + `/news/deleteHistory/${InputNewsIdList}`,{
            params: {
                userId: InputUserId
            }
        })
    },
    //修改个人作品
    updateWorks(newsUpdateDTO){
        return Instance.put(path.baseUrl + '/news/update', newsUpdateDTO);
    },
    //点赞新闻功能
    updateLikeNum(InputNewsId, InputUserId){
        return Instance.put(path.baseUrl + '/news/updateLikeNum',null,{
            params: {
                newsId: InputNewsId,
                userId: InputUserId
            }
        })
    },
    //收藏新闻功能
    updateFavoriteNum(InputNewsId, InputUserId){
        return Instance.put(path.baseUrl + '/news/updateFavoriteNum',null,{
            params: {
                newsId: InputNewsId,
                userId: InputUserId
            }
        })
    },
    //修改新闻浏览量功能
    updateViewNum(InputNewsId, InputUserId){
        return Instance.put(path.baseUrl + '/news/updateViewNum',null,{
            params: {
                newsId: InputNewsId,
                userId: InputUserId
            }
        })
    },
    //根据id获取新闻
    getNewsById(newsId,InputUserId){
        return Instance.get(path.baseUrl + '/news/getById',{
            params: {
                ids: newsId,
                userId: InputUserId
            }
        });
    },
    //获取全部的新闻分类
    getAllNewsCategory(){
        return Instance.get(path.baseUrl + '/news-category/getAll')
    },
    //为用户推送新闻
    pushNews(InputUserId, InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + '/news/pushNews',{
            params: {
                userId: InputUserId,
                current: InputCurrent,
                size: InputSize
            }
        })
    },
    //条件查询新闻
    getNewsInCondition(newsDTO){
        return Instance.post(path.baseUrl + '/news/getAllInCondition', newsDTO)
    },
    //查找--查找某用户点赞过的新闻
    getNewsByUserLike(InputUserId, InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + '/news/getNewsByUserLike',{
            params: {
                userId: InputUserId,
                current: InputCurrent,
                size: InputSize
            }
        })
    },
    //查找--查找某用户收藏过的新闻
    getNewsByUserFavorite(InputUserId, InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + '/news/getNewsByUserFavorite',{
            params: {
                userId: InputUserId,
                current: InputCurrent,
                size: InputSize
            }
        })
    },
    //查找--查找某用户新闻浏览记录
    getNewsByUserHistory(InputUserId, InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + '/news/getNewsByUserHistory',{
            params: {
                userId: InputUserId,
                current: InputCurrent,
                size: InputSize
            }
        })
    },
    //查找--查找相关阅读
    getNewsByRelated(cId, newsId){
        return Instance.get(path.baseUrl + '/news/getNewsByRelated',{
            params: {
                categoryId: cId,
                currentNewsId: newsId
            }
        })
    },

    //获取热搜榜数据
    getHotSearchList(){
        return Instance.get(path.baseUrl + '/news/getHotSearchList')
    },
    //#endregion


    //#region 关于新闻评论
    //发布新闻评论
    addNewsComment(userComment){
        return Instance.post(path.baseUrl + '/user-comment/add', userComment);
    },
    //删除新闻评论
    deleteNewsComment(newsCommentId){
        return Instance.delete(path.baseUrl + `/user-comment/delete/${newsCommentId}`)
    },
    //查找某一条新闻的所有评论
    getUserCommentByNewsId(newsId, InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + `/user-comment/getAllByNewsId/${newsId}`,{
            params: {
                current: InputCurrent,
                size: InputSize
            }
        })
    },

    //#endregion


    //#region 关于用户
    //用户注册
    userRegister(uLOrR_DTO){
        return Instance.post(path.baseUrl + "/user/register", uLOrR_DTO);
    },
    //用户信息修改
    updateUser(userDTO){
        return Instance.put(path.baseUrl + "/user/updateUser", userDTO);
    },
    //用户登录
    UserLogin(InputId, InputPhone, InputPassword){
        return Instance.post(path.baseUrl + "/user/signIn", null, {
            params: {
                id: InputId,
                phone: InputPhone,
                password: InputPassword
            }
        });
    },
    //根据id获取用户
    getUserById(UserId){
        return Instance.get(path.baseUrl + '/user/getById',{
            params: {
                ids: UserId
            }
        });
    },

    //作者资格申请
    authorApply(authorApplication){ 
        return Instance.post(path.baseUrl + '/user/authorApply',authorApplication)
    },
    //#endregion


    //#region 关于通知
    //删除已读消息
    deleteReadNotice(noticeId){
        return Instance.delete(path.baseUrl + `/notice/deleteReadNotice/${noticeId}`)
    },
    //标记消息已读
    markNoticeAsRead(noticeIds, userId){
        return Instance.get(path.baseUrl + `/notice/markNoticeAsRead/${noticeIds}`,{
            params: {
                userId: userId
            }
        })
    },
    //获取我的消息
    getNoticeByUserId(InputUserId, InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + '/notice/getNoticeByUserId',{
            params: {
                userId: InputUserId,
                current: InputCurrent,
                size: InputSize
            }
        })
    },
    //或群全服消息
    getGlobalNotice(InputCurrent=null, InputSize=null){
        return Instance.get(path.baseUrl + '/notice/getGlobalNotice',{
            params: {
                current: InputCurrent,
                size: InputSize
            }
        })
    },

    //#endregion
}

export default api;